//
//  UIBarButtonItem+Extension.swift
//  weibo
//
//  Created by zcp on 16/5/14.
//  Copyright © 2016年 zcp. All rights reserved.
//

import UIKit
//UIBarButtonItem的分类
extension UIBarButtonItem {

    convenience init(imageName: String,target: AnyObject?, action: Selector) {
        let btn = UIButton()
        btn.setBackgroundImage(UIImage(named: imageName), forState: UIControlState.Normal)
        btn.setBackgroundImage(UIImage(named: imageName+"_highlighted"), forState: UIControlState.Highlighted)
        btn.sizeToFit()
        btn.addTarget(target, action: action, forControlEvents: UIControlEvents.TouchUpInside)
        self.init(customView: btn)
    }

    

}
